<template>
	<div>
		<div class="publish-top">
			<div class="left-icon" @click="handleBack"> 
				<img src="../../../assets/images/left.png"/>
			</div>
			<p>个性签名</p>
			<span @click="handleSubmit">提交</span>
		</div>
		<div class="sign-content">
			<textarea placeholder="请输入你的个性签名~" v-model="texts" class="text" @change="changeText" maxlength="50"></textarea>
			<p>还可以输入{{num - texts.length}}个字</p>
		</div>
	</div>
</template>

<script>
	import axios from "axios";
	import user from '../../../utils/isLogin';
	
	export default{
		data(){
			return{
				texts : '',
				num : 50
			}
		},
		created(){
			let plusReady = ()=>{
				
			}
			if (window.plus) {
		      plusReady();
		    } else {
		      document.addEventListener("plusready", plusReady, false);
		    }
		},
		components:{
			
		},
		methods:{
			handleBack(){
				var signature = plus.webview.currentWebview();
				plus.webview.close(signature);
//				plus.webview.getWebviewById('mine').reload();
			},
			changeText (e){
				this.texts = e.target.value;	
			},
			handleSubmit (){
				let texts = this.texts;
				var userId = JSON.parse(window.localStorage.getItem( 'userInfo' )).userId;
				if(texts == ''){
					plus.nativeUI.toast('请输入内容');
					return;
				}
				axios.post(user.src + '/index/user/edit_user_desc' , {
					id: userId,
					desc: texts
				})
				.then((res)=> {
					if(res.data.status == 200){
						plus.nativeUI.toast('更改成功~');
						plus.webview.getWebviewById('modify').reload();
						var signature = plus.webview.currentWebview();
						plus.webview.close(signature);
						plus.webview.getWebviewById('mine').reload();
					}
					if(res.data.status == 1029){
						plus.nativeUI.toast('修改失败~');
					}
				})
				.catch(function (error) {  
				});
			}
		}
	}
</script>

<style lang='less' scoped>

html,body{
		padding: 0;
		margin: 0;
		width: 100%;
		height: 100%;
		background: #f6f6f6;
	}
	*{
		margin: 0;
		padding: 0;
	}
	ul,li{
		list-style: none;
	}
	.publish-top{
		height: 60px;
		background:@default-blue;
		box-shadow: 0px 0px 8px 1px #999;
		padding-top: 70px;
		display:flex;
		justify-content: space-between;				
		.left-icon{
			width: 90px;	
			img{
				width: 15px;
				height: 26px;
				margin-left: 31px;
			}
		}
		p{		
			color: #fff;
			font-size: 28px;
			text-align: center;
			text-indent: 50px;
		}
		span{
			display: block;
			width: 170px;
			color: #fff;
			font-size: 28px;
			text-align: center;
		}
	}
	.sign-content{
		padding: 30px 24px; 
		background: #fff;
		.text{
				display: block;
				padding-bottom: 21px;
				height: 400px;
				width: 100%;
				border: none;
				font-size: 32px;
				color: #999;
				line-height: 44px;
				outline:none;
				border-radius: 5px;
			}
		p{
			font-size: 22px;
			color: #bebebe;
			text-align: right;
		}
	}
</style>